package neves.android.etmg.sprite;

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;


public class GameSprite implements MovableObject {


	
	protected String name = "X";
	protected Bitmap objImage = null;
	
	protected int posX = 0;
	protected int posY = 0;

	protected int spriteType; 	
	protected int shiftX = 0;
	protected int shiftY = 0;
	
	protected boolean visible = true;
	//private ArrayList<int[]> shiftArray = null;
	
	public GameSprite(String newName , int sprType){
		name = newName;
		spriteType = sprType;
	}
	
	public String GetName(){
		return name;
	}
	
	public int GetType(){
		return spriteType;
	}
	
	@Override
	public int[] GetPos() {
		// TODO Auto-generated method stub
		return new int[]{posX,posY};
	}

	@Override
	public void SetPos(int px, int py) {
		// TODO Auto-generated method stub
		posX = px;
		posY = py;
	}
	
	@Override
	public void SetShift(int shiftx, int shifty){
		// TODO Auto-generated method stub
		shiftX = shiftx;
		shiftY = shifty;
	}
	
	@Override
	public void Update() {
		// TODO Auto-generated method stub
		posX += shiftX;
		posY += shiftY;
		
		shiftX = 0 ;
		shiftY = 0 ;
		
	}
	
	@Override
	public int[] GetUpdatedPos() {
		// TODO Auto-generated method stub
		return new int[]{posX+shiftX,posY+shiftY};
	}
	
	public boolean IsVisible(){
		return visible;
	}
	
	
	public void DoDraw(Canvas canvas, int onScreenX,int onScreenY, Paint errorPaint){
		if(GetImage()!=null){
			canvas.drawBitmap(GetImage(), onScreenX, onScreenY, null);
		}else{
			
			canvas.drawText(name, onScreenX, onScreenY+10, errorPaint);
		}
	}
	
	
	public void SetImage(Bitmap thisIm){
		objImage = thisIm;
	}
	
	public Bitmap GetImage(){
		return objImage;
	}
	
	public void SetImageSize(int width,int height){
		if(objImage!=null){
			objImage = objImage.createScaledBitmap(
					objImage, width, height, true);
		}
	}
	
	public boolean HasMoveDemend(){
		if(shiftX==0 && shiftY ==0){
			return false;
		}
		return true;
	}
}
